﻿using System;
using Ninject;
using Legazpi.Payroll.Services.Interfaces;
using Emz.Core.Models;
using Legazpi.Payroll.Web.Helpers;

namespace Legazpi.Payroll.Web.PopupBoxes
{
    public partial class AdjustmentDialogBox : System.Web.UI.Page
    {
        [Inject]
        public IAdjustmentService _adjustmentService { get; set; }

        protected Adjustment Model { get; private set; }

        protected void Page_Load(object sender, EventArgs e)
        {            

            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                int id;
                int.TryParse(Request.QueryString["id"], out id);
                if (id > 0)
                {
                    //Update Data
                    Model = _adjustmentService.GetById(id);
                }
            }
            //New Data
            Model = Model ??  new Adjustment { Id = 0 };
            


            //Bind Dropdowns
            AccountType.ToAdjAccountTypeSelectList(Model.AccountType);
            AccountSign.ToAdjAccountSignSelectList((int)Model.AccountSignEnum);

        }
    }
}